//index.js
//获取应用实例
const app = getApp()
var pd = {}
Page({
  changeSize: function(e) {
    this.data.icon.size = e.detail.value;
    this.setData(this.data);
  },
  changeOpacity: function(e) {
    this.data.icon.opacity = e.detail.value;
    this.setData(this.data);
  },
  initiate: function(e) {
    this.setData({
      loading : true
    });
    wx.navigateTo({
      url: '../main/main?num=' + this.data.icon.size + '&k=' + this.data.index +'&grade=' + this.data.iindex,
    });
 },
  initiateBook :function(){
    wx.navigateTo({
      url: '../ErrorBook/ErrorBook'
    });

  },
  data: {
    defaultSize: 'mini',
    primarySize: 'default',
    warnSize: 'default',
    disabled: false,
    plain: false,
    loading: false,

    userInfo: {
      avatarUrl: "", //用户头像
      nickName: "", //用户昵称
    },

    icon: {
      size: 20,
      opacity: 8
    },
    aarray: ['一年级', '二年级', '三年级'],
    oobjectArray: [{
        iid: 0,
        nname: '一年级'
      },
      {
        iid: 1,
        nname: '二年级'
      },
      {
        iid: 2,
        nname: '三年级'
      }
    ],
    iindex: 0,


    array: ['简单', '中等', '困难'],
    objectArray: [{
        id: 0,
        name: '简单'
      },
      {
        id: 1,
        name: '中等'
      },
      {
        id: 2,
        name: '困难'
      }
    ],
    index: 1,
  },

  add_address_fun: function() {
    wx.navigateTo({
      url: 'add_address/add_address',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    /**
     * 获取用户信息
     */
    wx.getUserInfo({
      success: function(res) {
        console.log(res);
        var avatarUrl = 'userInfo.avatarUrl';
        var nickName = 'userInfo.nickName';
        that.setData({
          [avatarUrl]: res.userInfo.avatarUrl,
          [nickName]: res.userInfo.nickName,
        })
      }
    })
  },
  onShow: function() {
    this.setData({
      loading: false //重置loading
    })
  },


  bindPickerChange: function(e) {
    this.setData({
      iindex: e.detail.value
    })
  },

  ChangeDifficulty: function(e) {
    this.setData({
      index: e.detail.value
    })
  }
})